<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
  <style>
    .el-page-header__content{
      color: white;
    }
  </style>
</head>
<body>
<div id="app">
  <el-page-header style="background-color: black;
            color: white;line-height: 60px" @back="goBack" content="修改学生信息">
  </el-page-header>
  <el-card style="width: 600px;height: 700px;margin: 0 auto">
    <el-form label-width="80px">
      <el-form-item label="学生姓名:">
        <el-input type="text" v-model="s.name"></el-input>
      </el-form-item>
      <el-form-item label="学生年龄:">
        <el-input type="text" v-model="s.age"></el-input>
      </el-form-item>
      <el-form-item label="学生性别:">
        <el-input type="text" v-model="s.gender"></el-input>
      </el-form-item>
      <el-form-item label="专业:">
        <el-select v-model="s.major" placeholder="请选择专业">
          <el-option label="计算机" value="计算机"></el-option>
          <el-option label="工商管理" value="工商管理"></el-option>
          <el-option label="应用化学" value="应用化学"></el-option>
          <el-option label="地理科学" value="地理科学"></el-option>
          <el-option label="生物科学" value="生物科学"></el-option>
          <el-option label="统计学" value="统计学"></el-option>
          <el-option label="市场营销" value="市场营销"></el-option>
          <el-option label="人力资源管理" value="人力资源管理"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="电话号码:">
        <el-input type="text" v-model="s.phoneNumber"></el-input>
      </el-form-item>
      <el-form-item label="身份证:">
        <el-input type="text" v-model="s.identityCard"></el-input>
      </el-form-item>
      <el-form-item label="学号:">
        <el-input type="text" v-model="s.getId"></el-input>
      </el-form-item>
      <el-form-item label="入学时间:">
        <el-date-picker
                v-model="s.created"
                type="date"
                placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <center>
        <el-button style="margin-top: 50px" type="success" @click="update()">修改学生信息</el-button>
      </center>
      </el-form-item>
    </el-form>
  </el-card>

</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
  let v = new Vue({
    el: '#app',
    data: function () {
      return {
        s: {
          name: "",
          age:"",
          gender:"",
          major: "",
          phoneNumber:"",
          identityCard:"",
          getId: "",
          created:""
        },
        studentArr:[],

      }
    },
    methods:{
      update(){
        //发出商品请求
        axios.post("/student/update",v.s).then(function (response) {
          location.href="/admin.html";
        })
      },
      goBack(){
        history.back();//返回上一级
      }

    },
    created:function () {
      axios.get("/student/select").then(function (response) {
        v.studentArr = response.data;
      })
      axios.get("/student/update/selectById"+location.search).then(function (response) {
        v.s = response.data;
      })
    }

  })
</script>
</html>